package com.mdb.open.epay.utils;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.util.RandomUtil;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class NoGenUtil {

    /**
     * 生成隨機OTP驗證碼
     */
    public static String genRandomOtpCode(){
        return RandomUtil.randomNumbers(6);
    }

    /**
     * 生成簽約流水號（訂單號）TODO 生成規則
     * QP+客戶編號+时间戳+随机码
     */
    public static String genSignSerialNo() {
        return "QPSIGN" +
                LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.PURE_DATETIME_PATTERN)) +
                RandomUtil.randomNumbers(4);
    }

    /**
     * 生成簽約號 TODO 生成規則
     */
    public static String genSignNo() {
        return "QP" + LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.PURE_DATETIME_PATTERN)) +
                RandomUtil.randomNumbers(4);
    }

    public static String genReqRef() {
        return "REF" + LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.PURE_DATETIME_PATTERN)) +
                RandomUtil.randomNumbers(4);
    }

    /**
     * 生成交易訂單號 TODO 生成規則
     */
    public static String genOrderNo() {
        String str = LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.PURE_DATETIME_PATTERN)).substring(2);
        return "QPS" + str +
                RandomUtil.randomNumbers(4);
    }

    /**
     * 生成退款訂單號 TODO 生成規則
     */
    public static String genRefundOrderNo() {
        String str = LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.PURE_DATETIME_PATTERN)).substring(2);
        return "QPSR" + str +
                RandomUtil.randomNumbers(4);
    }
}
